package com.hyz.util;

import com.hyz.model.entity.LoginUser;
import com.hyz.model.entity.User;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Component;

/**
 * @author HGD
 * @date 2022/10/22 10:36
 */
@Component
public class GetUser {
    public User getUser() {
        Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
        return ((LoginUser) principal).getUser();
    }
}
